﻿<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\web\View;
use backend\models\service\AdminService as Admin;
?>

<div class="pushactivity-form">
    <article class="center">
        <?php $form = ActiveForm::begin([
            'fieldConfig'=>[
                'template'=>"<div><div class=\"col-sm-3\">{label}</div>\n<div class=\"col-sm-9\">{input}</div>\n{error}</div>",
            ]
        ]); ?>
        <?=$form->field($model, 'username')->textInput(['maxlength' => 20,'placeholder' => "请输入渠道名称"])->label('渠道名称')?>
        <?= $form->field($model, 'id',['template'=>'<div style="height:50px;"><div class="col-xs-3">{label}</div><div class="col-xs-">{input}{error}</div><div class="col-xs-4" style="margin-top:5px;">自动生成</div></div>'])->label('渠道ID')->hiddenInput(['value' => 1]) ?>
        <?=$form->field($model, 'pid')->dropDownList(Admin::items('2'), ['prompt' => '请选择合作方'])->label('所属合作方账号')?>
        <?=$form->field($model, 'cost')->textInput(['maxlength' => 20])->label('成本（选填）')?>
        <?=$form->field($model, 'remark')->textArea(['maxlength' => 20])->label('备注（选填）')?>
        <?= Html::submitButton('保存创建', ['class'=>'create-channel btn btn-primary','name' =>'submit-button']) ?>
        <?php ActiveForm::end(); ?>
    </article>
</div>
<script>
 $(function(){
    $(".create-channel").click(function(){
        var username = $("#adminservice-username").val(); 
        console.log(username);
        if(username == ''){
            alert('渠道名称不能为空');
            return false;
        }
        var o_name = $('#adminservice-pid').val();
        console.log(o_name);
        if(o_name == ''){
            alert('请选择所属合作方账号');
            return false;
        }
    })
});
</script>